package com.cd.hospital.www.web;

import java.util.List;
import java.util.Map;

import com.cd.hospital.common.utils.PageUtils;
import com.cd.hospital.common.utils.Query;
import com.cd.hospital.common.utils.R;
import com.cd.hospital.modules.entity.NewsTagsEntity;
import com.cd.hospital.modules.service.NewsTagsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 文章标签
 * 
 * @author weirdor
 * @email 179946422@qq.com
 * @date 2017-10-12 11:33:46
 */
@RestController
@RequestMapping("/modules/newstags")
public class NewsTagsController {
	@Autowired
	private NewsTagsService newsTagsService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("modules:newstags:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<NewsTagsEntity> newsTagsList = newsTagsService.queryList(query);
		int total = newsTagsService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(newsTagsList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("modules:newstags:info")
	public R info(@PathVariable("id") Integer id){
		NewsTagsEntity newsTags = newsTagsService.queryObject(id);
		
		return R.ok().put("newsTags", newsTags);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("modules:newstags:save")
	public R save(@RequestBody NewsTagsEntity newsTags){
		newsTagsService.save(newsTags);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("modules:newstags:update")
	public R update(@RequestBody NewsTagsEntity newsTags){
		newsTagsService.update(newsTags);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("modules:newstags:delete")
	public R delete(@RequestBody Integer[] ids){
		newsTagsService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
